home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: tanmoy@qcd.Lanl.GOV (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c,comp.lang.c.moderated
- Subject: Re: Integral promotion problem
- Date: 11 Mar 1996 19:29:14 -0600
- Organization: Los Alamos National Laboratory
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4i2k1a$8ju@solutions.solon.com>
- References: <31404525.26295649@dub-news-svc-3.compuserve.com>
- <4i169k$ht@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <4i169k$ht@solutions.solon.com>
- johnb@pivotal-dm.ccmail.compuserve.com (John Bain) writes:
- <snip>
- JB: "The integral promotions are performed. If the operand is unsigned, the
- JB: result is computed by subtracting the value from the largest value of
- JB: the promoted type. If the operand is signed, the result is computed by
- JB: converting the promoted operand to the corresponding unsigned type,
- JB: applying ~, and converting it back to the unsigned type."
-
- Hmmm. I don't have the standard right here, but I do not remember it
- being quite that precise. I think all bits are reversed which leads to
- an implementation defined value; but I do not remember a requirement
- that this be consistent with unsigned->signed conversion. (I will
- follow up again if I am wrong.)
-
- JB:
- JB: I didn't believe that the implementation defined unsigned->signed
- JB: conversions were happening, but I didn't believe the results I was
- JB: seeing either!
-
- Integral promotion promotes unsigned short to unsigned int only if int
- cannot hold all possible values of unsigned short. I do not remember
- exactly what it was, but either I thought you said that your shorts
- were _shorter_ than your ints or you were talking about oromotion of
- short and not unsigned short. In either case, you never get unsigned
- int. So you never need the rule for unsigned to signed conversion.
-
- JB:
- JB: Incidentally, I assume that when it says "if the operand is unsigned" it
- JB: means _before_ promotion?
-
- No.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-